package flychess.entity;

import flychess.util.UserInput;
public abstract class Player {
    /**
     * 玩家抽象类，封装玩家的各种信息
     */
    protected PlayerType playerType;
    private String playerName; // 玩家的角色名
    private String goAndStop;  // 走或停表示设置
    private int playerPos;     // 对战中玩家的当前位置
    private String playerFullIcon;   // 玩家在地图中的图标(全角)
    private String playerSemiIcon;   // 玩家在地图中的图标(半角)
    private String playerID;

    public abstract int rollDice();
    public void setPlayerInfo(int playerPos, String playerFullIcon, String playerSemiIcon, String goAndStop) {
        this.playerPos = playerPos;
        this.playerFullIcon = playerFullIcon;
        this.playerSemiIcon = playerSemiIcon;
        this.goAndStop = goAndStop;
    }

    /**
     * 玩家选择角色的方法
     * @param rival 另一个玩家
     */
    public void selectRole(Player rival) {
        System.out.printf("请%s选择角色:  ", this.playerID);
        int choice = UserInput.getInputNum(1, PlayerInfoOption.roleSelected.size(), playerType);
        if (rival.playerName != null) {
            while (PlayerInfoOption.roleSelected.get(choice - 1).equals(rival.playerName)) {
                System.out.printf("您选择了与%s相同的角色，请选择不同的角色\n", rival.playerID);
                choice = UserInput.getInputNum(1, PlayerInfoOption.roleSelected.size(), playerType);
            }
        }
        this.playerName = PlayerInfoOption.roleSelected.get(choice - 1);
    }
    // 设置get和set方法
    public String getPlayerName() {
        return playerName;
    }

    public void setPlayerName(String playerName) {
        this.playerName = playerName;
    }

    public String getGoAndStop() {
        return goAndStop;
    }

    public void setGoAndStop(String goAndStop) {
        this.goAndStop = goAndStop;
    }

    public int getPlayerPos() {
        return playerPos;
    }

    public void setPlayerPos(int playerPos) {
        this.playerPos = playerPos;
    }

    public String getPlayerFullIcon() {
        return playerFullIcon;
    }

    public void setPlayerFullIcon(String playerFullIcon) {
        this.playerFullIcon = playerFullIcon;
    }

    public String getPlayerSemiIcon() {
        return playerSemiIcon;
    }

    public void setPlayerSemiIcon(String playerSemiIcon) {
        this.playerSemiIcon = playerSemiIcon;
    }

    public PlayerType getPlayerType() {
        return playerType;
    }

    public String getPlayerID() {
        return playerID;
    }

    public void setPlayerID(String playerID) {
        this.playerID = playerID;
    }
}